#include "widget.h"

#include <QGroupBox>
#include <QRadioButton>
#include <QCheckBox>
#include <QVBoxLayout>
#include <QGridLayout>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
{
    resize(1000, 800);

    //-----单选按钮对应的分组框-------
    QGroupBox *boxRadio = new QGroupBox("单选按钮组");

    QRadioButton *radio1 = new QRadioButton("radio1");
    QRadioButton *radio2 = new QRadioButton("radio2");
    QRadioButton *radio3 = new QRadioButton("radio3");

    QVBoxLayout *vLayout1 = new QVBoxLayout;
    vLayout1->addWidget(radio1);
    vLayout1->addWidget(radio2);
    vLayout1->addWidget(radio3);
    boxRadio->setLayout(vLayout1);

    //-----复选按钮对应的分组框-------
    QGroupBox *boxCheck = new QGroupBox("复选按钮组");

    QCheckBox *checkBox1 = new QCheckBox("checkBox1");
    QCheckBox *checkBox2 = new QCheckBox("checkBox2");
    QCheckBox *checkBox3 = new QCheckBox("checkBox3");
    QCheckBox *checkBox4 = new QCheckBox("checkBox4");

    QVBoxLayout *vLayout2 = new QVBoxLayout;

    vLayout2->addWidget(checkBox1);
    vLayout2->addWidget(checkBox2);
    vLayout2->addWidget(checkBox3);
    vLayout2->addWidget(checkBox4);

    boxCheck->setLayout(vLayout2);

    //-----混合按钮对应的分组框-------
    QGroupBox *box3 = new QGroupBox("混合按钮组");
    QRadioButton *radio11 = new QRadioButton("radio11");
    QRadioButton *radio22 = new QRadioButton("radio22");
    QCheckBox *checkBox11 = new QCheckBox("checkBox11");
    QCheckBox *checkBox22 = new QCheckBox("checkBox22");

    QVBoxLayout *vLayout3 = new QVBoxLayout;

    vLayout3->addWidget(radio11);
    vLayout3->addWidget(radio22);
    vLayout3->addWidget(checkBox11);
    vLayout3->addWidget(checkBox22);

    box3->setLayout(vLayout3);

    //对三个分组框进行布局
    QGridLayout *gLayout = new QGridLayout;
    gLayout->addWidget(boxRadio, 0, 0);
    gLayout->addWidget(boxCheck, 0, 2);
    gLayout->addWidget(box3, 1, 1);

    setLayout(gLayout);
}

Widget::~Widget()
{
}

